package com.demo.designmode.facade;

/**
 * @Author: jxm
 * @Description: 智能音箱（外观角色）
 * @Date: 2023-12-13 14:57
 * @Version: 1.0
 */
public class SmartAppliancesFacade {

    private Light light;
    private TV tv;
    private AirCondition airCondition;

    public SmartAppliancesFacade() {
        light = new Light();
        tv = new TV();
        airCondition = new AirCondition();
    }

    /**
     * 对外提供一个共同的接口
     * @param message
     */
    public void say(String message){
        if (message.contains("打开")){
            on();
        }else if(message.contains("关闭")){
            off();
        }
    }

    private void off() {
        System.out.println("睡觉了");
        light.off();
        tv.off();
        airCondition.off();
    }

    private void on() {
        System.out.println("起床了");
        light.on();
        tv.on();
        airCondition.on();
    }
}
